package com.wenx.unit2.chapter5;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class Chapter5 {
    public static void main(String[] args) {
        List<Object> result = Stream.of("hello world")
                .map(a -> a.split(""))
                .flatMap(Arrays::stream)
                .distinct()
                .collect(toList());
        result.forEach(System.out::println);

        List<Integer> numbers1 = Arrays.asList(1, 2, 3);
        List<Integer> numbers2 = Arrays.asList(3, 4);

        List<int[]> list = numbers1.stream()
                .flatMap(i -> numbers2.stream().map(j -> new int[]{i,j}))
                .collect(toList());
        list.forEach(ints -> {
            System.out.println("ints = " + ints[0] + " " + ints[1]);
        });
    }
}
